import UIKit

func main(){
    largerNumber(a: 1,b: 23)
}

func largerNumber(a:Int, b:Int){
    
    print( "a=\(a)")
    
}

main()
let datas = [1,2,3,4,5,6,7,8,9,10]
for item in datas where item > 4 {
    print(item)
}

protocol MyProtocol {
    func getNameMethod()
}
class Cat : MyProtocol{
    func getNameMethod() {
        
    }
}
class Dog{
    
}
//Cat 添加了协议才能添加拓展
extension MyProtocol where Self :Cat{
    func showName(){
        print("Cat")
    }
}
//Dog 没添加协议不能能添加拓展
extension MyProtocol where Self :Dog{
    func showName(){
        print("Dog")
    }
}

let dog = Dog()//没继承协议 没有拓展方法
let cat = Cat()//继承了协议 有拓展方法
cat.showName()


class test2:MyProtocol{
    func getNameMethod() {
        print( "我是协议方法，类似抽象类" )
        
        guard false else{
            print( "我是协议方法，类似抽象类2" )
            return
        }
        
        let  dateFormatter = DateFormatter.init()
        dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
        let utcTimeZone = TimeZone(abbreviation: "UTC")
        dateFormatter.timeZone = utcTimeZone
        
        let time = "2022-05-01T00:00:00+08:00"
        
        guard let dateFormatted = dateFormatter.date(from: time) else{
            print( "wu shi jian" )
            return
        }
        
        print( "dateFormatted\(dateFormatted)" )
        
        
        
        
        
    }
    
    
}
let test2Objc = test2()
test2Objc.getNameMethod()


